home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / WINVCOLL.ZIP / WINTUTOR.ZIP / WININF03.TXT < prev    next >
Encoding:
Text File  |  1996-02-03  |  5.3 KB  |  103 lines

  1.  
  2.  Introducing Windows 95 by Quantum / VLAD
  3.  ────────────────────────────────────────
  4.  
  5.   When VLAD started working on the Win95 problem (back when WinSurfer was
  6.   released), all we had to work with was the win32s update to win3.1 that
  7.   allowed win3.1 users to run (not very successfully) 32 bit win95/NT
  8.   applications.  Tracing through the code one day we noticed that every
  9.   exe started with loading the PE header with eax pointing to it and
  10.   jumping to the entrypoint (jmp [eax + 28h]).  So we changed the
  11.   entrypoint RVA to point to our code, pushed eax, did our code, popped
  12.   eax, and jumped to [eax + 28].  It worked, we had a win32s infector,
  13.   then we noticed we didn't actually have any way to infect.  There were
  14.   no ints and we really felt out of our depth and then to top it all off
  15.   we came across the ultimate way to go resident without infecting the
  16.   win3.1 shell and so PH33R was born.  About this time I left the scene
  17.   in an unexplainable burst of insane "oh my god I'm going to fail uni"
  18.   panic and that was about the end of the win32s/95/NT project.
  19.  
  20.   Just recently, uni ended.  I was on holidays, bored out of my skull,
  21.   and running win95, so I decided I'd give it another go.  To my surprise
  22.   the jmp [eax + 28] was gone, it was just a byproduct of win32s.  Instead
  23.   I just calculated the distance between the end of the exe and the
  24.   entrypoint, calculated the start of the virus code and subtracted the
  25.   two.  It worked, I had a win95/NT infector.  That is, 'cept for a little
  26.   matter of calling API...
  27.  
  28.  
  29.   The Day the World Changed
  30.   ─────────────────────────
  31.  
  32.   In the beginning there were memory locations and we manipulated what
  33.   our computer did by peeking and poking.  And it was good.  But this
  34.   was not to last, for on the horizon was the "port" and slowly we
  35.   learnt to communicate with attached devices by puting values in, and
  36.   pulling values out, of specific ports.
  37.  
  38.   After a while the computer was no longer young and we needed
  39.   something to keep things in check.  We needed a way to communicate
  40.   indirectly with the hardware and thus the interrupt was born.  Not
  41.   everyone liked the interrupt system but soon we all learnt to live
  42.   with it, to manipulate it, and use it to our advantage.
  43.  
  44.   Everyone that is, except one group at Microsoft - the guys who were
  45.   writing a "revolutionary" GUI called "Windows".  These guys were
  46.   looking for a way to split all the functions that were once provided
  47.   by interrupts into seperate, shared files called Dynamic Link
  48.   Librarys (Dll's).  And so the Application Program Interface (API) was
  49.   born.  API's made calling functions just that little bit harder and
  50.   admittedly sometimes completely impossible.  But the guys at Microsoft
  51.   had not yet taken away our interrupts and we still had (some) control
  52.   over the system with DPMI.
  53.  
  54.   Then the guys at Microsoft did it again.  Their latest concoction
  55.   eliminated interrupts and ports and yes, even memory locations.  For
  56.   "Windows 95/NT" is a true non-preemptive multitasking system or in
  57.   other words - a bully.  This ogre pushes programs around, squeezes
  58.   them into confined spaces, locks them out of restricted areas and,
  59.   worst of all, forces them into using a new, impossibly complex, method
  60.   of calling API.
  61.  
  62.   Which brings us to...
  63.  
  64.  
  65.   One drunk night at Microsoft
  66.   ────────────────────────────
  67.  
  68.   When the guys at Microsoft get drunk, they truly get drunk.  But rather
  69.   than running around with a cop's panties on their collective head and
  70.   stealing traffic cones, they designed a new call construct.
  71.  
  72.   In the spirit of Windows 3.1, the guys at Microsoft chose against using
  73.   interrupts.  In some ways this was good - programmers dont need to check
  74.   to see if dll's are in memory (although they could), and they can state
  75.   what dll's they need.  The way that Microsoft achieved this is through
  76.   the Import and Export Tables.  The Import table lets the programmer state
  77.   what functions they need from which dll's.  The Export table lets the
  78.   provider of the dll specify what functions it provides.
  79.  
  80.   The problem is, once the import table has been written it is set in stone.
  81.   There is no space to add any new entries and you cant move anything around.
  82.   Why ?  Well, mainly because of a certain jump table that can be ANYWHERE
  83.   in the exe.  To call an API the code calls a hardcoded address.  This
  84.   address points to an indirect jump which points to an entry in the import
  85.   table that is filled in (when the executable is loaded) with an address to
  86.   a similar jump table in the dll that pushes a value and jumps to the
  87.   function dispatcher which uses the values that are inserted in the dll's
  88.   export table.  To add an entry to the import table you would have to
  89.   move the current entries around so that you could fit it in.  This means
  90.   you have to change the jump table to point to the relocated entries, which
  91.   is impossible as the jump table can be ANYWHERE in the file and cannot be
  92.   located.
  93.  
  94.   The New Frontier
  95.   ----------------
  96.  
  97.   Windows 95 is a whole new platform.  It's a new challenge and although
  98.   a lot of things have been stacked against you - it IS possible.  So
  99.   get in there and start researching.  Research will be the end-all of
  100.   the VX/AV war, one way or the other.
  101.  
  102.  
  103.